package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources.NotFoundException;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.util.Log;
import androidx.annotation.FontRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.annotation.StyleRes;
import androidx.annotation.VisibleForTesting;
import o.aqu.n;

@RestrictTo({d.LIBRARY_GROUP})
public class asg {
    public final int ʻ;
    public final float ʼ;
    @Nullable
    public final String ʽ;
    public final int ˊ;
    public final float ˊॱ;
    public final float ˋ;
    private boolean ˋॱ = false;
    @Nullable
    public final ColorStateList ˎ;
    @Nullable
    public final ColorStateList ˏ;
    @FontRes
    private final int ˏॱ;
    @Nullable
    private Typeface ͺ;
    @Nullable
    public final ColorStateList ॱ;
    public final float ॱˊ;
    @Nullable
    public final ColorStateList ॱॱ;
    public final boolean ᐝ;

    public asg(Context context, @StyleRes int i) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(i, n.ॱᴵ);
        this.ˋ = obtainStyledAttributes.getDimension(n.ॱߺ, 0.0f);
        this.ˏ = asi.ˊ(context, obtainStyledAttributes, n.ॱꜝ);
        this.ˎ = asi.ˊ(context, obtainStyledAttributes, n.ॱﹶ);
        this.ॱ = asi.ˊ(context, obtainStyledAttributes, n.ॱᶫ);
        this.ˊ = obtainStyledAttributes.getInt(n.ॱᵔ, 0);
        this.ʻ = obtainStyledAttributes.getInt(n.ॱߵ, 1);
        int ˋ = asi.ˋ(obtainStyledAttributes, n.ᐝʾ, n.ᐝʿ);
        this.ˏॱ = obtainStyledAttributes.getResourceId(ˋ, 0);
        this.ʽ = obtainStyledAttributes.getString(ˋ);
        this.ᐝ = obtainStyledAttributes.getBoolean(n.ᐝˉ, false);
        this.ॱॱ = asi.ˊ(context, obtainStyledAttributes, n.ॱᵢ);
        this.ʼ = obtainStyledAttributes.getFloat(n.ॱⁱ, 0.0f);
        this.ॱˊ = obtainStyledAttributes.getFloat(n.ᐝˈ, 0.0f);
        this.ˊॱ = obtainStyledAttributes.getFloat(n.ॱﹺ, 0.0f);
        obtainStyledAttributes.recycle();
    }

    @VisibleForTesting
    @NonNull
    public Typeface ॱ(Context context) {
        if (this.ˋॱ) {
            return this.ͺ;
        }
        if (!context.isRestricted()) {
            try {
                this.ͺ = fv.ˎ(context, this.ˏॱ);
                if (this.ͺ != null) {
                    this.ͺ = Typeface.create(this.ͺ, this.ˊ);
                }
            } catch (UnsupportedOperationException e) {
            } catch (NotFoundException e2) {
            } catch (Throwable e3) {
                Log.d("TextAppearance", "Error loading font " + this.ʽ, e3);
            }
        }
        ॱ();
        this.ˋॱ = true;
        return this.ͺ;
    }

    public void ˋ(Context context, final TextPaint textPaint, @NonNull final fv.d dVar) {
        if (this.ˋॱ) {
            ˏ(textPaint, this.ͺ);
            return;
        }
        ॱ();
        if (context.isRestricted()) {
            this.ˋॱ = true;
            ˏ(textPaint, this.ͺ);
            return;
        }
        try {
            fv.ॱ(context, this.ˏॱ, new fv.d(this) {
                final /* synthetic */ asg ˋ;

                public void ˎ(@NonNull Typeface typeface) {
                    this.ˋ.ͺ = Typeface.create(typeface, this.ˋ.ˊ);
                    this.ˋ.ˏ(textPaint, typeface);
                    this.ˋ.ˋॱ = true;
                    dVar.ˎ(typeface);
                }

                public void ˋ(int i) {
                    this.ˋ.ॱ();
                    this.ˋ.ˋॱ = true;
                    dVar.ˋ(i);
                }
            }, null);
        } catch (UnsupportedOperationException e) {
        } catch (NotFoundException e2) {
        } catch (Throwable e3) {
            Log.d("TextAppearance", "Error loading font " + this.ʽ, e3);
        }
    }

    private void ॱ() {
        if (this.ͺ == null) {
            this.ͺ = Typeface.create(this.ʽ, this.ˊ);
        }
        if (this.ͺ == null) {
            switch (this.ʻ) {
                case 1:
                    this.ͺ = Typeface.SANS_SERIF;
                    break;
                case 2:
                    this.ͺ = Typeface.SERIF;
                    break;
                case 3:
                    this.ͺ = Typeface.MONOSPACE;
                    break;
                default:
                    this.ͺ = Typeface.DEFAULT;
                    break;
            }
            if (this.ͺ != null) {
                this.ͺ = Typeface.create(this.ͺ, this.ˊ);
            }
        }
    }

    public void ˎ(Context context, TextPaint textPaint, fv.d dVar) {
        int colorForState;
        ˊ(context, textPaint, dVar);
        textPaint.setColor(this.ˏ != null ? this.ˏ.getColorForState(textPaint.drawableState, this.ˏ.getDefaultColor()) : -16777216);
        float f = this.ˊॱ;
        float f2 = this.ʼ;
        float f3 = this.ॱˊ;
        if (this.ॱॱ != null) {
            colorForState = this.ॱॱ.getColorForState(textPaint.drawableState, this.ॱॱ.getDefaultColor());
        } else {
            colorForState = 0;
        }
        textPaint.setShadowLayer(f, f2, f3, colorForState);
    }

    public void ˊ(Context context, TextPaint textPaint, @Nullable fv.d dVar) {
        if (asj.ˋ()) {
            ˏ(textPaint, ॱ(context));
            return;
        }
        ˋ(context, textPaint, dVar);
        if (!this.ˋॱ) {
            ˏ(textPaint, this.ͺ);
        }
    }

    public void ˏ(@NonNull TextPaint textPaint, @NonNull Typeface typeface) {
        textPaint.setTypeface(typeface);
        int style = (typeface.getStyle() ^ -1) & this.ˊ;
        textPaint.setFakeBoldText((style & 1) != 0);
        textPaint.setTextSkewX((style & 2) != 0 ? -0.25f : 0.0f);
        textPaint.setTextSize(this.ˋ);
    }
}
